<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>会员登录</title>
		<link rel="stylesheet" href="<%=request.getContextPath()%>/resources/css/bootstrap.min.css" type="text/css" />
		<script src="<%=request.getContextPath()%>/resources/js/jquery-1.11.3.min.js" type="text/javascript"></script>
		<script src="<%=request.getContextPath()%>/resources/js/bootstrap.min.js" type="text/javascript"></script>
		<script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/jquery-heima-0.0.1.js" ></script>
		<!-- 引入自定义css文件 style.css -->
		<script type="text/javascript">
			$(function(){
				//登录按钮,绑定点击事件
				$("#submit").click(function(){
					//获取表单数据,用户名和密码
					var param = $("#loginForm").serialize();
					//数据提交服务器端
					HM.ajax("<%=request.getContextPath()%>/userServlet",param,function(data){
						//data是响应回来的json
						if(data.code==1){
							//登录成功,跳转到首页
							location.href="<%=request.getContextPath()%>/index.jsp";
						}else if(data.code==0){
							//登录失败,json的键message取出数据
							$("#loginMsg").html(data.message).css("color","red");
							document.getElementById("inputPassword3").value="";
						}
					});
				});
			});
		</script>
	
	</head>

	<body>
		<div class="container-fluid"  style="max-width: 1370px;">
			<!--头部-->
			<div id="header" style="min-height: 130px;"><jsp:include page="header.jsp" /></div>
			<div class="container-fluid" style="height:460px;width: 98%; background:#FF2C4C url('resources/img/loginbg.jpg') no-repeat;">
				<div class="row">
					<div class="col-md-7">
					</div>

					<div class="col-md-5">
						<div style="width:460px;border:1px solid #E7E7E7;padding:20px 0 20px 30px;border-radius:5px;margin-top:60px;background:#fff;">
							<font style="color: #666;font-size: 22px;font-weight: normal;padding-right: 17px;">会员登录</font>USER LOGIN 
							<div id="loginMsg">&nbsp;</div>
							<form class="form-horizontal" id="loginForm" method="post">
								<input type="hidden" name="method" value="userLogin">
								<div class="form-group">
									<label for="username" class="col-sm-2 control-label">用户名</label>
									<div class="col-sm-6">
										<input type="text" class="form-control" id="username" placeholder="请输入用户名" name="username">
									</div>
								</div>
								<div class="form-group">
									<label for="password" class="col-sm-2 control-label">密码</label>
									<div class="col-sm-6">
										<input type="password" class="form-control" id="password" placeholder="请输入密码" name="password">
									</div>
								</div>
								<div class="form-group">
									<label for="inputPassword3" class="col-sm-2 control-label">验证码</label>
									<div class="col-sm-3"style="margin-right: 0;padding-right: 0;">
										<input type="text" class="form-control" name="code" id="inputPassword3" placeholder="请输入验证码">
									</div>
									<div class="col-sm-3" style="margin-left: 5px;padding-left: 0;">
										<img src="<%=request.getContextPath()%>/userServlet?method=checkCode" onclick="fnChange()" id="code" />
									</div>
								</div>
								<div class="form-group">
									<div class="col-sm-offset-2 col-sm-10">
										<div class="checkbox">
											<label>
									          <input type="checkbox" onclick="aut()" id="aoutLogin" name="aoutLogin" value="aoutLogin"> 自动登录
									        </label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
											<label>
									          <input type="checkbox" id="rember" name="rember" value="rember"> 记住密码
									        </label>
										</div>
									</div>
								</div>
								<div class="form-group">
									<div class="col-sm-offset-2 col-sm-10">
										<input type="button" width="100" value="登录" id="submit" border="0" style="background-color:#CD062D;height:35px;width:100px;color:white;">
									</div>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
			<!--尾部-->
			<div id="footer"  style="min-height: 203px;"><jsp:include page="foot.jsp" /></div>
		</div>
	</body>
	<script>
	if(HM.cookieValue("u")!=null&&HM.cookieValue("u")!=null){
		document.getElementById("password").value=HM.cookieValue("p");
		document.getElementById("username").value=HM.cookieValue("u");
	}
	function aut(){
		if(document.getElementById("aoutLogin").checked==true){
			document.getElementById("rember").checked=true;
		}
	}
	function fnChange() {
		var code = document.getElementById("code");
		var date = new Date().getTime();
		code.src="<%=request.getContextPath()%>/userServlet?method=checkCode&a="+date;
	}
	</script>
</html>